(function(){"use strict";BX.namespace("BX.Landing.SliderHelper");BX.Landing.SliderHelper.ACTION_INIT="init";BX.Landing.SliderHelper.ACTION_ADD="add";BX.Landing.SliderHelper.ACTION_REMOVE="remove";BX.Landing.SliderHelper.ACTION_UPDATE="update";BX.Landing.SliderHelper.ACTIVE_CLASS="slick-initialized";BX.Landing.SliderHelper.init=function(e,i){i=i?i:BX.Landing.SliderHelper.ACTION_INIT;var l=BX.Landing.SliderHelper.makeCarouselRelativeSelector(e);var r=e.block.querySelectorAll(l);if(r.length>0){if(i==BX.Landing.SliderHelper.ACTION_UPDATE&&BX.Landing.SliderHelper.isSliderActive(r)){BX.Landing.SliderHelper.destroy(e)}BX.Landing.SliderHelper.initBase(l);if(i==BX.Landing.SliderHelper.ACTION_UPDATE&&BX.Landing.SliderHelper.isSliderActive(r)){BX.Landing.SliderHelper.goToSlide(l,e,i);BX.Landing.SliderHelper.setSelection(e)}}};BX.Landing.SliderHelper.destroy=function(e){var i=BX.Landing.SliderHelper.makeCarouselRelativeSelector(e);var l=e.block.querySelectorAll(i);if(l.length>0&&BX.Landing.SliderHelper.isSliderActive(l)){e.block.slickCurrentSlide=$(i).slick("slickCurrentSlide");if(window.getSelection().rangeCount>0){var r=window.getSelection().getRangeAt(0);e.block.savedRange={sCont:r.startContainer,sOffset:r.startOffset,eCont:r.endContainer,eOffset:r.endOffset}}$(i).slick("unslick")}};BX.Landing.SliderHelper.isSliderActive=function(e){var i=false;Object.keys(e).forEach(function(l){if(BX.hasClass(e[l],BX.Landing.SliderHelper.ACTIVE_CLASS)){i=true}});return i};BX.Landing.SliderHelper.initBase=function(e){var i=$(e).data("init-classes-exclude");if(i&&BX.type.isArray(i)){i.forEach(function(i){if(i.selector&&i.class){$(e).parent().find(i.selector).removeClass(i.class)}})}$.HSCore.components.HSCarousel.init(e,{accessibility:false});if(BX.Landing.getMode()=="edit"){$(e).slick("slickSetOption","infinite",false,true)}};BX.Landing.SliderHelper.makeCarouselRelativeSelector=function(e,i){if(e.block.carouselRelativeSelector){return e.block.carouselRelativeSelector}i=i||"js-carousel";var l=[];if(e.block){var r=[];if(e.card){r=e.block.querySelectorAll("."+e.card.className.split(/\s+/).join("."))}else if(e.node){r=e.node}else if(e.data&&e.data.selector){r=e.block.querySelectorAll(e.data.selector.split("@")[0])}if(!BX.type.isArray(r)){r=[r]}r.forEach(function(e){var r=BX.findParent(e,{className:i}),n="";if(r){r.classList.forEach(function(e){if(e.indexOf("slick-")==-1){n+="."+e}});if(l[l.length-1]!=n){l.push(n)}}})}if(l.length==0){l=["."+i]}l.forEach(function(i,r){l[r]=e.makeRelativeSelector(i)});e.block.carouselRelativeSelector=l.join(",");return e.block.carouselRelativeSelector};BX.Landing.SliderHelper.setSelection=function(e){var i=e.block.savedRange;if(i){var l=document.createRange();l.setStart(i.sCont,i.sOffset);l.setEnd(i.eCont,i.eOffset);var r=window.getSelection();r.removeAllRanges();r.addRange(l)}};BX.Landing.SliderHelper.goToSlide=function(e,i,l){if(!l){return}var r=parseInt(i.block.slickCurrentSlide);var n=i.card;if(i.block.querySelector(e).dataset.rows&&parseInt(i.block.querySelector(e).dataset.rows)>1){n=BX.findParent(i.card,{className:"slick-slide"})}if(n){var t=parseInt(n.dataset.slickIndex)}switch(l){case BX.Landing.SliderHelper.ACTION_ADD:BX.Landing.SliderHelper.goToNewSlideAfterAdd(e,r,t);break;case BX.Landing.SliderHelper.ACTION_REMOVE:BX.Landing.SliderHelper.goToNewSlideAfterRemove(e,r,t);break;case BX.Landing.SliderHelper.ACTION_UPDATE:BX.Landing.SliderHelper.goToSlideAfterUpdate(e,r);break;default:}};BX.Landing.SliderHelper.goToNewSlideAfterAdd=function(e,i,l){if(BX.type.isNumber(l)&&BX.type.isNumber(i)){var r=$(e).slick("slickGetOption","slidesToShow");r=r===true?1:r;if(l-i>=r){$(e).slick("slickGoTo",i,true);$(e).slick("slickGoTo",i+1,false)}else{$(e).slick("slickGoTo",i,true)}}};BX.Landing.SliderHelper.goToNewSlideAfterRemove=function(e,i,l){if(BX.type.isNumber(l)&&BX.type.isNumber(i)){$(e).slick("slickGoTo",Math.min(i,l),true)}};BX.Landing.SliderHelper.goToSlideAfterUpdate=function(e,i){if(BX.type.isNumber(i)){$(e).slick("slickGoTo",i,true)}}})();
//# sourceMappingURL=carousel_helper.map.js